package com.icinfo.cloud.provider.punish.common.publicity.enums;

import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：公示变更操作
 * @author shishengyao
 * @description
 * @date 2022/10/14
 */
public enum CasePublicityModifyEnum {
    /**
     * 非诉执行当事人类别枚举
     */
    FIRST_PUBLICITY("0", "初次公示",""),
    CORRECT_PUBLICITY("1", "更正公示","DT1SQGZGSSPB"),
    REVOKE_PUBLICITY("2", "撤销公示","DT1SQCXGSSPB");

    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;
    /**
     * 描述
     */
    @Getter
    private String documentKindCode;

    CasePublicityModifyEnum(String code, String des,String documentKindCode) {
        this.code = code;
        this.des = des;
        this.documentKindCode = documentKindCode;
    }


    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author xiangyuyu
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (CasePublicityModifyEnum e : CasePublicityModifyEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return code;
    }

    /**
     * 描述：根据code获取value
     *
     * @param documentKindCode 文件类型代码
     * @return {@link String }
     * @author shishengyao
     * @date 2022/10/21
     */
    public static String getCodeByDocumentKindCode(String documentKindCode) {
        if (ObjectUtils.isEmpty(documentKindCode)) {
            return null;
        }
        for (CasePublicityModifyEnum e : CasePublicityModifyEnum.values()) {
            if (documentKindCode.equals(e.getDocumentKindCode())) {
                return e.getCode();
            }
        }
        return "";
    }
    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author xiangyuyu
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (CasePublicityModifyEnum e : CasePublicityModifyEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }

    /**
     * 描述：校验code是否是合法枚举
     *
     * @param documentKindCode 文件类型代码
     * @return boolean
     * @author shishengyao
     * @date 2022/10/22
     */
    public static boolean isLegalEnumCodeByKindCode(String documentKindCode) {
        boolean flag = false;
        for (CasePublicityModifyEnum e : CasePublicityModifyEnum.values()) {
            if (e.getDocumentKindCode().equalsIgnoreCase(documentKindCode)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
